import request from '@/utils/request'

// 获取所有策略
export function getAllStrategies() {
  return request({
    url: '/api/strategies',
    method: 'get'
  })
}

// 根据ID获取策略
export function getStrategyById(id) {
  return request({
    url: `/api/strategies/${id}`,
    method: 'get'
  })
}

// 搜索策略
export function searchStrategies(keyword) {
  return request({
    url: '/api/strategies/search',
    method: 'get',
    params: { keyword }
  })
}

// 根据因子ID获取相关策略
export function getStrategiesByFactorId(factorId) {
  return request({
    url: `/api/strategies/factor/${factorId}`,
    method: 'get'
  })
}

// 创建策略
export function createStrategy(data) {
  return request({
    url: '/api/strategies',
    method: 'post',
    data
  })
}

// 更新策略
export function updateStrategy(id, data) {
  return request({
    url: `/api/strategies/${id}`,
    method: 'put',
    data
  })
}

// 删除策略
export function deleteStrategy(id) {
  return request({
    url: `/api/strategies/${id}`,
    method: 'delete'
  })
}

// 添加因子到策略
export function addFactorToStrategy(strategyId, factorId) {
  return request({
    url: `/api/strategies/${strategyId}/factors/${factorId}`,
    method: 'post'
  })
}

// 从策略移除因子
export function removeFactorFromStrategy(strategyId, factorId) {
  return request({
    url: `/api/strategies/${strategyId}/factors/${factorId}`,
    method: 'delete'
  })
}

// 更新策略中因子的权重
export function updateFactorWeight(strategyId, factorId, weight) {
  return request({
    url: `/api/strategies/${strategyId}/factors/${factorId}/weight`,
    method: 'put',
    params: { weight }
  })
} 